import { utcToBeijing } from '../../utils';
import { Column, CreateDateColumn, Entity, PrimaryColumn } from 'typeorm';

@Entity({ name: 'history' })
export class History {
  @PrimaryColumn({
    comment: '历史今天ID',
  })
  id: number;

  @Column({
    comment: '标题',
  })
  title: string;

  @Column({
    comment: '分类',
  })
  day: string;

  @Column({
    comment: '分类',
  })
  date: string;

  @CreateDateColumn({
    type: 'timestamp',
    transformer: {
      to(value: Date): number {
        return value ? value.getTime() : null;
      },
      from(value: number) {
        // 将UTC时间转换为北京时间
        return utcToBeijing(value);
      },
    },
  })
  createDate: Date;

  @Column({
    comment: '详情',
    length: 10000
  })
  content: string

  @Column({
    comment: '图片url集合',
    length: 1000,
    nullable: true
  })
  picUrl: string
  // "day": "11/30",
  // "date": "383年11月30日",
  // "title": "肥水之战",
  // "e_id": "14580"
}
